package org.esisar.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import org.esisar.model.Model;
import org.esisar.model.Picture;

public class SearchStatementCreator implements StatementCreator{


	private PreparedStatement preparedStatement;

	@Override
	public PreparedStatement readStatement(Connection connection, String field,String value) throws SQLException {

		preparedStatement = connection.prepareStatement("select * from picture where " + field + " like "+  "'%" + value + "%'" );

		return preparedStatement;

	}

	@Override
	public PreparedStatement addStatement(Connection connection, Model model) throws SQLException {
		throw new UnsupportedOperationException("Method not implemented");
	}

	@Override
	public PreparedStatement deleteStatement(Connection connection,
			List<Long> keys) throws SQLException {
		throw new UnsupportedOperationException("Method not implemented");
	}

	@Override
	public PreparedStatement updateStatement(Connection connection, Model user)
			throws SQLException {
		throw new UnsupportedOperationException("Method not implemented");
	}

	@Override
	public Model fillModel(ResultSet rs) throws SQLException {
		PictureStatementCreator pictureStatementCreator = new PictureStatementCreator();
		Picture picture = (Picture) pictureStatementCreator.fillModel(rs);
		
		
		return picture;
	}

}
